<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/spectrum.css" />
		<style type="text/css">
			.hy-js-fieldarea label{ border: 2px solid #ddd; width: 100%;background: #ddd;height: 40px;border-radius: 4px;line-height: 30px;padding-left: 10px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;}
		     .am-icon-photo{ cursor: pointer;}
		</style>
	</head>

	<body>
		<div class="am-g">
			{include file='../Common/hy_header.html'}
			<form class="am-form hy-js-form" style="touch-action: pan-y; -webkit-user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
				<div class="am-g am-margin-top">
					<div class="am-u-sm-2 am-text-right">
						属性名称
					</div>
					<div class="am-u-sm-4 am-u-end">
						<input type="text" name="attr_name" value="{$art.name}" placeholder="如：颜色" class="am-input-sm">
						<input type="hidden" name="old_name" id="old_name" value="{$art.name}" />
					</div>
				</div>
                 {if $_C.DIGLOSSIA==1}
				<div class="am-g am-margin-top">
					<div class="am-u-sm-2 am-text-right">
						英文名称
					</div>
					<div class="am-u-sm-4 am-u-end">
						<input type="text" name="en_attr_name" value="{$art.en_name}" placeholder="如：color" class="am-input-sm">
					</div>
				</div>
				{/if}
				<div class="am-tabs am-margin"  data-am-tabs="{ noSwipe: 1}">
					<ul class="am-tabs-nav am-nav am-nav-tabs">
						<li class="am-active"><a hidefocus="true" href="#tab1">基本详情</a>
						</li>
					</ul>
					<div class="am-tabs-bd ">
						<div class="am-tab-panel am-fade  am-active am-in" id="tab1">
							<table class="am-table am-table-striped am-table-hover hy-table-main">
								<thead>
									<tr>
										<th class="table-title">名称</th>
										{if $_C.DIGLOSSIA==1}
										<th class="table-type">英文名称</th>
										{/if}
										<th class="table-date">缩略图</th>
										<th class="table-date">颜色</th>
										<th class="table-set">操作</th>
									</tr>
								</thead>
								<tbody class="hy-js-chdata">
									<tr>
										<td>
											<input type="text" placeholder="如:红色" name="name" id="" value="" />
										</td>
										<td>
											<input type="text" placeholder="如:white" name="en_name" id="" value="" />
										</td>
										<td>
											<div class="am-u-sm-4">
												<input type="text" name="thumb" class="am-input-sm">
											</div>
											<div class="am-u-sm-2">
												<img id="hy-thumb" class="hy-js-cutimg" style="height: 30px;" src="{$_C.hy_path}images/logo2.png" >
											</div>
											<div class="am-u-sm-4 am-u-end">
												<button class="am-btn am-btn-primary am-btn-xs hy-js-uploadimg">上传</button>
											</div>
										</td>
										<td>
											<input class="hy-spectrum" type="text"  name="color" id="" value="#0e90d2" />
										</td>
										<td>
											<div class="am-btn-toolbar">
												<div class="am-btn-group am-btn-group-xs">
													<a href="javascript:;" class="am-btn am-btn-default am-btn-xs am-text-secondary hy-js-newchdata"><span class="am-icon-plus"></span> 新增</a>
													<button data-hide='4' class="am-btn am-btn-default am-btn-xs am-text-danger hy-js-delchdata hy-hide"><span class="am-icon-trash-o"></span> 删除</button>
												</div>
											</div>
										</td>
									</tr>
									{foreach from=$art.value item=val key=key}
									<tr>
										
										<td>
											<input type="text" placeholder="如:尺寸" name="name" id="" value="{$val}" />
										</td>
										<td>
											<input type="text" placeholder="如:white" name="en_name" id="" value="{$art['en_value'][{$key}]}" />
										</td>
										<td>
											<div class="am-u-sm-4">
												<input type="text" name="thumb" class="am-input-sm" value="{$art['thumb'][{$key}]}">
											</div>
											<div class="am-u-sm-2">
												<img id="hy-thumb" class="hy-js-cutimg" style="height: 30px;" {if $art['thumb'][{$key}]}src="{$art['thumb'][{$key}]}" {else} src="{$_C.hy_path}images/logo2.png" {/if}>
											</div>
											<div class="am-u-sm-4 am-u-end">
												<button class="am-btn am-btn-primary am-btn-xs hy-js-uploadimg">上传</button>
											</div>
										</td>
										<td>
											<input class="hy-spectrum" type="text"  name="color" id="" value="{$art.color[{$key}]|default:'#0e90d2'}" />
										</td>
										<td>
											<div class="am-btn-toolbar">
												<div class="am-btn-group am-btn-group-xs">
													<button data-hide='4' data-id="{$art.id}" class="am-btn am-btn-default am-btn-xs am-text-danger hy-js-delchdata"><span class="am-icon-trash-o"></span> 删除</button>
												</div>
											</div>
										</td>
									</tr>
									{/foreach}
								</tbody>
							</table>
						</div>
						<input type="hidden" name="id" value="{$id}" />
					</div>
			</form>
			<div class="am-margin">
				<button type="button" class="am-btn am-btn-primary hy-js-submit am-btn-xs">提交保存</button>
			</div>
			</div>
		</div>
		{include file='../Common/hy_footer.html'}
		<script type="text/javascript" src="{$_C.hy_path}js/spectrum.js"></script>
		<script type="text/javascript" src="{$_C.hy_path}js/hy.base.js"></script>
		<script type="text/javascript">
		    hungry.spectrum.run();
		    hungry.spectrum.run('.hy-spectrum2');
			hy_uploadimg('/attr_thumb',{},function(result,_this){
		    	if(typeof(result[0])!='undefined')
		    	{
		    		var _parent=_this.parent().parent();
		        	_parent.find('#hy-thumb').attr('src',result[0]);
		        	_parent.find('input[name=thumb]').val(result[0]).focus();
		       }
		    })
				hy_submit('index.php?g=admin&m=goods&a={$action}');
				    $('.hy-js-newchdata').live('click',function(e){
				    	e.preventDefault();
				    	$(this).next('.hy-js-delchdata').show();
				    	$(this).hide();
				    	var html='<tr><td><input type="text" placeholder="如:紅色" name="name" id="" value="" /></td>';
				    	{if $_C.DIGLOSSIA==1}
				    	 html+='<td><input type="text" placeholder="如:white" name="en_name" id="" value="" /></td>';
				    	{/if}
				    	html+='<td><div class="am-u-sm-4"><input type="text" name="thumb" class="am-input-sm" value=""></div><div class="am-u-sm-2"><img id="hy-thumb" style="height: 30px;"  src="{$_C.hy_path}images/logo2.png" ></div><div class="am-u-sm-4 am-u-end"><button class="am-btn am-btn-primary am-btn-xs hy-js-uploadimg">上传</button></div></td>';
				    	html+='<td><input class="hy-spectrum" type="text"  name="color" id="" value="#0e90d2" /></td>';
				    	html+='<td><div class="am-btn-toolbar"><div class="am-btn-group am-btn-group-xs"><button   class="am-btn am-btn-default am-btn-xs am-text-secondary hy-js-newchdata"><span class="am-icon-plus"></span> 新增</button><button data-hide="4"   class="hy-hide am-btn am-btn-default am-btn-xs am-text-danger hy-js-delchdata"><span class="am-icon-trash-o"></span> 删除</button></div></div></td></tr>';
				    	$('.hy-js-chdata').prepend(html);
				    	 hungry.spectrum.run();
				    	
				    });
				    $('.hy-js-delchdata').live('click',function(e){
				    	e.preventDefault();
				    	var _this=$(this);
				        var hide=$(this).attr('data-hide');
				     	var parent='';
				    	var id=_this.attr('data-id');
				    	
				    		 if(hide)
					        {
						       for(i=0;i<hide;i++)
				              {
					               parent+='.parent()';
					          }
					        }
					        eval('_this'+parent+'.remove()');
				    	
				    })
		</script>
	</body>

</html>